namespace Crux.Core.MongoDb;
/// <summary>
/// IMongoRepositoryBaseOfT
/// </summary>
public interface IMongoRepositoryBase<out TContext, T, TPrimary>
    where T : IGenericEntity<TPrimary>
    where TContext : IMongoDBContext
{
    /// <summary>
    ///
    /// </summary>
    TContext Context { get; }
    /// <summary>
    ///
    /// </summary>
    /// <param name="entity"></param>
    void Add(T entity);
    /// <summary>
    ///
    /// </summary>
    /// <param name="entities"></param>
    void AddRange(IEnumerable<T> entities);
    /// <summary>
    ///
    /// </summary>
    /// <param name="entity"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task AddAsync(
        T entity,
        CancellationToken cancellationToken = default);
    /// <summary>
    ///
    /// </summary>
    /// <param name="entities"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task AddRangeAsync(
        IEnumerable<T> entities,
        CancellationToken cancellationToken = default);
    /// <summary>
    ///
    /// </summary>
    /// <param name="entity"></param>
    void Update(T entity);
    /// <summary>
    ///
    /// </summary>
    /// <param name="entities"></param>
    void UpdateRange(IEnumerable<T> entities);
    /// <summary>
    ///
    /// </summary>
    /// <param name="where"></param>
    /// <param name="expression"></param>
    void Update(
        Expression<Func<T, bool>> where,
        Expression<Func<T, T>> expression);
    /// <summary>
    ///
    /// </summary>
    /// <param name="entity"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task UpdateAsync(
        T entity,
        CancellationToken cancellationToken = default);
    /// <summary>
    ///
    /// </summary>
    /// <param name="entities"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task UpdateRangeAsync(
        IEnumerable<T> entities,
        CancellationToken cancellationToken = default);
    /// <summary>
    ///
    /// </summary>
    /// <param name="where"></param>
    /// <param name="expression"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task UpdateAsync(
        Expression<Func<T, bool>> where,
        Expression<Func<T, T>> expression,
        CancellationToken cancellationToken = default);
    /// <summary>
    ///
    /// </summary>
    /// <param name="entity"></param>
    void Delete(T entity);
    /// <summary>
    ///
    /// </summary>
    /// <param name="entities"></param>
    void DeleteRange(IEnumerable<T> entities);
    /// <summary>
    ///
    /// </summary>
    /// <param name="where"></param>
    void Delete(Expression<Func<T, bool>> where);
    /// <summary>
    ///
    /// </summary>
    /// <param name="entity"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task DeleteAsync(
        T entity,
        CancellationToken cancellationToken = default);
    /// <summary>
    ///
    /// </summary>
    /// <param name="entities"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task DeleteRangeAsync(
        IEnumerable<T> entities,
        CancellationToken cancellationToken = default);
    /// <summary>
    ///
    /// </summary>
    /// <param name="where"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task DeleteAsync(
        Expression<Func<T, bool>> where,
        CancellationToken cancellationToken = default);
    /// <summary>
    ///
    /// </summary>
    /// <param name="where"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    IQueryable<T> Get(
        Expression<Func<T, bool>>? where = null,
        CancellationToken cancellationToken = default);
    /// <summary>
    ///
    /// </summary>
    /// <param name="orderExpressions"></param>
    /// <param name="where"></param>
    /// <param name="option"></param>
    /// <param name="desc"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Pageable<T> GetByPage(
        List<OrderExpression<T>> orderExpressions,
        Expression<Func<T, bool>>? where = null,
        PageOption option = default,
        bool desc = false,
        CancellationToken cancellationToken = default);
    /// <summary>
    ///
    /// </summary>
    /// <param name="where"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task<IQueryable<T>> GetAsync(
        Expression<Func<T, bool>>? where = null,
        CancellationToken cancellationToken = default);
    /// <summary>
    ///
    /// </summary>
    /// <param name="orderExpressions"></param>
    /// <param name="where"></param>
    /// <param name="option"></param>
    /// <param name="desc"></param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task<Pageable<T>> GetByPageAsync(
        List<OrderExpression<T>> orderExpressions,
        Expression<Func<T, bool>>? where = null,
        PageOption option = default,
        bool desc = false,
        CancellationToken cancellationToken = default);
}